package com.how2java.springboot.mapper;

import com.how2java.springboot.pojo.Category;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Mapper
@Service //不加这个的话 controller里面会爆红，说没有这个类型的bean，但是不影响 加上这个 boot会默认这是个bean
public interface CategoryMapper {
    @Select("select * from category_")
    List<Category> findall();
    @Insert("insert into category_(name) values (#{name})")
    public int save(Category category);
    @Delete("delete from category_ where id = #{id}")
    public void delete(int id);
    @Select("select * from category_ where id = #{id}")
    public Category get(int id);
    @Update("update category_ set name = #{name} where id =#{id}")
    public int update(Category category);
}
